﻿using CPF;
using CPF.Animation;
using CPF.Charts;
using CPF.Controls;
using CPF.Drawing;
using CPF.Shapes;
using CPF.Styling;
using CPF.Svg;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CPFUI.IControl
{
    public class IMListBoxItem : ListBoxItem
    {
        public UserInfo UserInfo;
        public IMListBoxItem(UserInfo userInfo)
        {
            UserInfo = userInfo;
            
        }
        //模板定义
        protected override void InitializeComponent()
        {
            DataContext = UserInfo;
            IsAntiAlias = true;
            Width = 276;
            Height = 60;
            Children.Add(new Ellipse()
            {
                IsAntiAlias = true,
                Width = 45,
                Height = 45,
                MarginLeft = 12,
                StrokeFill = Color.Transparent,
                Fill = string.Format("url({0}) Clamp Fill 0,0,0,0", UserInfo.HeadImage) 
            });
            Children.Add(new TextBlock
            {
                MarginLeft = 65,
                MarginTop = 11,
                MarginRight = 40,
                Text = UserInfo.NickName,
                
            });
            Children.Add(new TextBlock
            {
                MarginLeft = 65,
                MarginTop = 32,
                MarginRight = 40,
                Foreground = Color.Gray,
                Text = UserInfo.Description
            });
            Children.Add(new Panel()
            {
                IsAntiAlias = true,
                BorderFill = Color.Red,
                Background = Color.Red,
                CornerRadius = new CornerRadius(9),
                MarginRight = 10,
                MinWidth = 23,
                MinHeight = 18,
                Children = {  new TextBlock()
                {

                    MarginLeft = 3,
                    MarginRight = 3,
                    VerticalAlignment = VerticalAlignment.Center,
                    TextAlignment = TextAlignment.Center,
                    Foreground = Color.White,
                    Text = "99+",
                    FontSize = 9
                } }
            });
        }

#if !DesignMode //用户代码写到这里，设计器下不执行，防止设计器出错
        protected override void OnInitialized()
        {
            base.OnInitialized();

        }
        //用户代码

#endif
    }
}
